
***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Figures"
clear all
log using Log_A1.log, replace

clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
set matsize 10000
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures"

***Set of fixed effects
qui tabulate year_around_ipo, generate(deventyear)

**Create a random variable with mean 0, to include as "benchmark" coefficient of 0 on t=-1. All other event-years will be relative to t=-1
set seed 123
generate randnum = uniform()-0.5

**Program to save coefficients
capture program drop foo
program foo, eclass
	tempname bmat
    tempname vmat
	matrix `bmat' = e(b)
	matrix `bmat'[1,1] = 0
	matrix `vmat' = e(V)
	matrix `vmat'[1,1] = 0
	ereturn repost b = `bmat'
	ereturn repost V = `vmat'
end
label var randnum "-1"

*Label fixed effects
label var deventyear1 "-2"
label var deventyear3 "0"
label var deventyear4 "1"
label var deventyear5 "2"


**Defining events
gen ipo_ev1=deventyear1*ipo
gen ipo_ev3=deventyear3*ipo
gen ipo_ev4=deventyear4*ipo
gen ipo_ev5=deventyear5*ipo
gen noipo_ev1=deventyear1*(1-ipo)
gen noipo_ev3=deventyear3*(1-ipo)
gen noipo_ev4=deventyear4*(1-ipo)
gen noipo_ev5=deventyear5*(1-ipo)

*Label events
label var ipo_ev1 "-2"
label var noipo_ev1 "-2"
label var ipo_ev3 "0"
label var noipo_ev3 "0"
label var ipo_ev4 "1"
label var noipo_ev4 "1"
label var ipo_ev5 "2"
label var noipo_ev5 "2"


**First, keeping coefficients for UK IPO firms
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5 if countryname=="United Kingdom", fe cluster(id) 
foo
estimate store ipo_UK

coefplot (ipo_UK,yline(0) clpattern(shortdash) msymbol(C) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(United Kingdom)   ///
 plotlabels( "Completed IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.08 0.04)) ylab(-0.08(0.04)0.04) 

graph save Comp_UK, replace 
 
 
**Keeping coefficients for FR IPO firms
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5 if countryname=="France", fe cluster(id) 
foo
estimate store ipo_FR

coefplot (ipo_FR,yline(0) clpattern(shortdash) msymbol(C) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(France)    ///
 plotlabels( "Completed IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.08 0.04)) ylab(-0.08(0.04)0.04) 

graph save Comp_FR, replace  
 
 
 
**Keeping coefficients for Germany IPO firms
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5 if countryname=="Germany", fe cluster(id) 
foo
estimate store ipo_DE

coefplot (ipo_DE,yline(0) clpattern(shortdash) msymbol(C) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(Germany)   ///
 plotlabels( "Completed IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.16 0.04)) ylab(-0.16(0.04)0.04) 
 
graph save Comp_DE, replace  
 
**Keeping coefficients for Sweden IPO firms
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5 if countryname=="Sweden", fe cluster(id) 
foo
estimate store ipo_SE

coefplot (ipo_SE,yline(0) clpattern(shortdash) msymbol(C) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(Sweden)    ///
 plotlabels( "Completed IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.08 0.04)) ylab(-0.08(0.04)0.04) 
 
graph save Comp_SE, replace   
 
 
**Keeping coefficients for Italy IPO firms
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5 if countryname=="Italy", fe cluster(id) 
foo
estimate store ipo_IT

coefplot (ipo_IT,yline(0) clpattern(shortdash) msymbol(C) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(Italy)   ///
 plotlabels( "Completed IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.08 0.04)) ylab(-0.08(0.04)0.04)  
 
graph save Comp_IT, replace   
  
 
***Create variable for other counties
gen others=1
replace others=0 if countryname=="United Kingdom" | countryname=="France" | countryname=="Germany" | countryname=="Sweden" | countryname=="Italy"

**Keeping coefficients for firms in other countries
set more off
qui xtreg wroa randnum ipo_ev1 noipo_ev1 ipo_ev3 noipo_ev3 ipo_ev4 noipo_ev4 ipo_ev5 noipo_ev5 if others==1, fe cluster(id) 
foo
estimate store ipo_others

coefplot (ipo_others,yline(0) clpattern(shortdash) msymbol(C) msize(large)), ///
keep(randnum ipo_ev1 ipo_ev3 ipo_ev4 ipo_ev5) /// 
order( ipo_ev1 randnum ipo_ev3 ipo_ev4 ipo_ev5) ///
 yline(0)  clpattern(shortdash)  ciopts(recast(rcap) clpattern(shortdash))  ///
 citop vertical  title(Other countries)   ///
 plotlabels( "Completed IPOs" ) xline(2.5, lpattern(dash) lcolor(black)) ysc(r(-0.08 0.04)) ylab(-0.08(0.04)0.04)    

graph save Comp_Oth, replace  
 
graph combine Comp_UK.gph Comp_FR.gph Comp_DE.gph Comp_SE.gph Comp_IT.gph Comp_Oth.gph, common xcommon  col(3)  row(2)    
 
graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\OROA_by_country.tif", as(tif) replace 
 
graph export A1.pdf, replace 
 
***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Figures"
log close
graphlog using Log_A1.log, lspacing(1) replace
